package com.ala4.oxcafe.service.impl;

import com.ala4.oxcafe.boot.page.PageDomain;
import com.ala4.oxcafe.entity.DictData;
import com.ala4.oxcafe.entity.DictType;
import com.ala4.oxcafe.repository.DictDataRepository;
import com.ala4.oxcafe.repository.DictTypeRepository;
import com.ala4.oxcafe.service.DictInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典数据服务
 *
 * @author PING
 * @version 1.0.0
 * @date 2025/8/14 10:37
 */
@Service
@AllArgsConstructor
public class DictInfoServiceImpl implements DictInfoService {

    private final DictTypeRepository dictTypeRepository;

    private final DictDataRepository dictDataRepository;


    @Override
    public IPage<DictType> dictTypePage(PageDomain pageDomain, DictType dictType) {
        return dictTypeRepository.selectDictTypePage(pageDomain, dictType);
    }

    @Override
    public List<DictData> dictData(String typeCode) {
        return dictDataRepository.list(Wrappers.<DictData>lambdaQuery().eq(DictData::getTypeCode, typeCode));
    }
}
